from django.shortcuts import render
import os
# Create your views here.
from django.http import HttpResponse
from website.models import Majors, Colleges, Provinces

def dashboard(request):
    return render(request, 'dashboard.html')

def user(request):
    return render(request, 'user.html')

def icons(request):
    return render(request, 'icons.html')

def table(request):
    return render(request, 'table.html')

def list_all_files(rootdir):
    _files = []
    list = os.listdir(rootdir)
    for i in range(len(list)):
        path = os.path.join(rootdir, list[i])
        if os.path.isdir(path):
            _files.extend(list_all_files(path))
        if os.path.isfile(path):
            _files.append(path)
    return _files
def filterCol(request):
    print("call")
    file_dir = "./static/video"
    allvideos = list_all_files(file_dir)
    print(allvideos)
    context = {
        'allMajors': allvideos,
        }
    return render(request, 'dashboard.html', context)


def typography(request):
    return render(request, 'typography.html')

def maps(request):
    return render(request, 'maps.html')

def notifications(request):
    return render(request, 'notifications.html')

def profile(request):
    allFilterMajors = Majors.objects.all()
    userList = {}
    subjectList = ["chinese", "math", "english", "phy", "chem", "bio", "geo", "his","tech","poli","rank","city"]
    if request.POST:
        for i in subjectList:
            userList[i] = request.POST[i] if len(request.POST[i])!=0 else "未知"
    return render(request, 'user.html', userList)
